/*
 * @Author: Wangjun
 * @Date: 2023-08-03 09:51:03
 * @LastEditTime: 2023-08-25 16:33:47
 * @LastEditors: Wangjun
 * @Description:
 * @FilePath: \nodex\nodelogic\op_or.go
 * hnxr
 */
package nodelogic

import (
	"gitee.com/hnxr_1/nodex"
)

func init() {
	nodex.Reister(new(Or))
}

type Or struct {
	nodex.Node
	X1 nodex.Boolean `remark:"输入1"`
	X2 nodex.Boolean `remark:"输入2"`
	X3 nodex.Boolean `remark:"输入3"`
	X4 nodex.Boolean `remark:"输入4"`
	X5 nodex.Boolean `remark:"输入5"`
	X6 nodex.Boolean `remark:"输入6"`
	Y  nodex.Boolean `remark:"输出Y,,out"`
}

func (m *Or) GetModelID() int {
	return nodex.ModLogic
}

/**
 * @description:
 * @return {*}
 */
func (m *Or) GetName() string {
	return "OR"
}
func (m *Or) RegData() []byte {
	return nodex.MakeRegData(m, "或运算", m.GetName(), "")
}

func (m *Or) Calc() (err error) {
	if m.EnQ {
		if *m.X1.Bad || *m.X2.Bad || *m.X3.Bad || *m.X4.Bad || *m.X5.Bad || *m.X6.Bad {
			m.Bad = true
			return //不计算
		}
	}

	m.Y.Value = m.X1.Value || m.X2.Value || m.X3.Value || m.X4.Value || m.X5.Value || m.X6.Value
	m.Bad = false
	return
}
